<template>
    <div>
        <el-dialog :title="title" :visible.sync="open" width="60%" destroy-on-close append-to-body>
            <el-form :model="formData" size="small" label-width="120px" ref="form">
                <el-form-item label="任务内容" prop="cate">
                    {{ formData.taskContent }}
                </el-form-item>
                <el-form-item label="辅助信息" prop="cate">
                    {{ formData.helpContent }}
                </el-form-item>
                <el-form-item label="反馈内容" prop="cate" v-if="formData.status == 2">
                    {{ formData.submit }}
                </el-form-item>
                <el-form-item label="反馈附件" prop="cate" v-if="formData.attachs && formData.attachs.length > 0 && formData.status == 2">
                    <uploader :files="formData.attachs" :canUpload="false" @onDownload="handleTaskAttachDownload" width="80px" />
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="close">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import dialogMixin from "@/mixins/dialogMixin";
import Uploader from "@/views/components/uploader/index.vue";
import { getTaskDetail } from "@/api/response/task";
import { getHandleSonTaskList } from "@/api/response/handle";

export default {
    name: "HandleDetailDialog",
    mixins: [dialogMixin],
    components: { Uploader },
    data() {
        return {
            title: "任务详情",
            open: false,
            formData: {
                attachs: [],
            },
            sonTasks: [],
        };
    },
    methods: {
        //完成任务调
        showDialog(data) {
            getTaskDetail(data.id).then(res => {
                this.formData = res.data;
                if (this.formData.parentId == "0") {
                    this.getSonTasks();
                }
                this.open = true;
            });
        },
        getSonTasks() {
            getHandleSonTaskList(this.formData.id).then(res => {
                this.sonTasks = res.data;
            });
        },
        handleTaskAttachDownload(row) {
            // 下载附件
            this.download(`com/ComAttach/download/${row.attachid}`, {}, `${row.attachname}.${row.attachtype}`);
        },
        handleSonTaskDetail(row) {
            this.$refs.taskDetail.showDialog(row);
        },
    },
};
</script>

<style lang="scss" scoped>
.task-report {
    padding: 0 20px 20px;
}
</style>
